<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::group(['middleware' => ['auth:api']], function () {
    Route::get('/dashboard', 'Api\DashboardController@index');
    Route::get('/release/server', 'Api\ReleaseController@server');
    Route::get('/user', 'Api\OAuthController@user');
    // categories
    Route::get('/categories', 'Api\CategoryController@index');
    Route::post('/categories', 'Api\CategoryController@store')->middleware('permission:manage-category');
    Route::put('/categories/{category}', 'Api\CategoryController@update')->middleware('permission:manage-category');
    Route::delete('/categories/{category}', 'Api\CategoryController@destroy')->middleware('permission:manage-category');

    // posts
    Route::get('/posts/latest', 'Api\PostController@latestPostOfEachCategory');
    Route::get('/posts', 'Api\PostController@index');
    Route::get('/posts/{post}', 'Api\PostController@show');
    Route::get('/posts/{post}/edit', 'Api\PostController@edit');
    Route::post('/posts', 'Api\PostController@store')->middleware('permission:manage-post');
    Route::put('/posts/{post}', 'Api\PostController@update')->middleware('permission:manage-post');
    Route::delete('/posts/{post}', 'Api\PostController@destroy')->middleware('permission:manage-post');
    Route::delete('/attachments/{attachment}', 'Api\AttachmentController@destroy');

    // Rbac
    Route::get('/permissions', 'Api\PermissionController@index');
    Route::post('/permissions', 'Api\PermissionController@store')->middleware('permission:manage-permission');
    Route::put('/permissions/{permission}', 'Api\PermissionController@update')->middleware('permission:manage-permission');
    Route::delete('/permissions/{permission}', 'Api\PermissionController@destroy')->middleware('permission:manage-permission');

    Route::get('/roles/{role}/permissions', 'Api\RoleController@permissions')->middleware('permission:manage-role');
    Route::put('/roles/{role}/permissions', 'Api\RoleController@setPermissions')->middleware('permission:manage-role');

    Route::get('/roles', 'Api\RoleController@index');
    Route::post('/roles', 'Api\RoleController@store')->middleware('permission:manage-role');
    Route::put('/roles/{role}', 'Api\RoleController@update')->middleware('permission:manage-role');
    Route::delete('/roles/{role}', 'Api\RoleController@destroy')->middleware('permission:manage-role');

    Route::put('/users/{user}/roles', 'Api\UserController@setRoles')->middleware('permission:manage-role');
    Route::put('/users/profile', 'Api\UserController@updateProfile');
    // Route::resource('/users', 'Api\UserController')->middleware('permission:manage-user');
    Route::resource('/users', 'Api\UserController'); //todo

    // ad position
    Route::get('/positions', 'Api\AdPositionController@index');
    Route::post('/positions', 'Api\AdPositionController@store')->middleware('permission:manage-ad');
    Route::put('/positions/{position}', 'Api\AdPositionController@update')->middleware('permission:manage-ad');
    Route::delete('/positions/{position}', 'Api\AdPositionController@destroy')->middleware('permission:manage-ad');
    // ad
    Route::post('/ads', 'Api\AdController@store')->middleware('permission:manage-ad');
    Route::put('/ads/{ad}', 'Api\AdController@update')->middleware('permission:manage-ad');
    Route::delete('/ads/{ad}', 'Api\AdController@destroy')->middleware('permission:manage-ad');
    // goods
    Route::resource('/types', 'Api\TypeController')->middleware('permission:manage-product');

    Route::get('/attrs/byTypeAndGoods', 'Api\AttrController@byTypeAndGoods')->middleware('permission:manage-product');
    Route::resource('/attrs', 'Api\AttrController')->middleware('permission:manage-product');
    Route::get('/specs/byTypeAndGoods', 'Api\SpecController@byTypeAndGoods')->middleware('permission:manage-product');
    Route::post('/specs/specPriceInput', 'Api\SpecController@specPriceInput')->middleware('permission:manage-product');
    Route::resource('/specs', 'Api\SpecController')->middleware('permission:manage-product');
    Route::put('/goods/{good}/attrs', 'Api\GoodsController@updateGoodsAttr')->middleware('permission:manage-product');

    Route::post('/goods', 'Api\GoodsController@store')->middleware('permission:manage-product');
    Route::get('/goods/{good}/edit', 'Api\GoodsController@edit');
    Route::put('/goods/{good}', 'Api\GoodsController@update')->middleware('permission:manage-product');
    Route::delete('/goods/{good}', 'Api\GoodsController@destroy')->middleware('permission:manage-product');
    // promotion activity
    Route::resource('/teamActivities', 'Api\TeamActivityController')->middleware('permission:manage-promotion');
    Route::resource('/flashSales', 'Api\FlashSaleController')->middleware('permission:manage-promotion');
    Route::resource('/coupons', 'Api\CouponController')->middleware('permission:manage-promotion');
    Route::resource('/user_coupons', 'Api\UserCouponController');
    // config
    Route::put('/configs/update_all', 'Api\ConfigController@updateAll')->middleware('permission:manage-config');
    Route::resource('/configs', 'Api\ConfigController')->middleware('permission:manage-config');
    // order
    Route::put('/orders/{order}/finish', 'Api\OrderController@finish');
    Route::get('/my_orders', 'Api\OrderController@userOrder');
    Route::put('/orders/{order}/confirm', 'Api\OrderController@confirm')->middleware('permission:manage-order');
    Route::post('/orders/{order}/delivery', 'Api\OrderController@delivery')->middleware('permission:manage-order');

    Route::get('/orders', 'Api\OrderController@index')->middleware('permission:manage-order');
    Route::get('/orders/{order}', 'Api\OrderController@show')->middleware('permission:manage-order');
    Route::post('/orders', 'Api\OrderController@store');
    Route::put('/orders/{order}', 'Api\OrderController@update')->middleware('permission:manage-order');
    Route::delete('/orders/{order}', 'Api\OrderController@destroy')->middleware('permission:manage-order');

    // address
    Route::resource('addresses', 'Api\AddressController');
    Route::put('addresses/{address}/default', 'Api\AddressController@setDefault');
    // cart
    Route::resource('carts', 'Api\CartController');
    // orderGoods
    Route::get('/my_order_goods', 'Api\OrderGoodsController@userOrderGoods');
    Route::resource('/orderGoods', 'Api\OrderGoodsController');
    // collection
    Route::resource('/collections', 'Api\CollectionController');
    // fadeback
    Route::resource('/fadebacks', 'Api\FadebackController');
    // integral
    Route::resource('/integrals', 'Api\IntegralController');
    Route::resource('/signins', 'Api\SigninController');
    // balance
    Route::get('/balances/record', 'Api\BalanceController@record');
    Route::resource('/balances', 'Api\BalanceController');
    // pay
    Route::get('/pay/{type}-{id}', 'Api\PayController@order');
    Route::get('/pay/Subject/{type}-{id}', 'Api\PayController@Subject');
    // comment
    Route::post('/comments', 'Api\CommentController@store');
    Route::put('/comments/{order}', 'Api\CommentController@update');
    Route::delete('/comments/{order}', 'Api\CommentController@destroy');

    Route::get('/distributions', 'Api\UserController@distribution');
    Route::get('/distributions/groupCount', 'Api\UserController@groupCount');

    Route::get('/donations/statistics', 'Api\DonationController@statistics');
    Route::resource('donations', 'Api\DonationController');
    Route::get('/courses/group', 'Api\CourseController@group');

    Route::get('/courses', 'Api\CourseController@index');
    Route::get('/courses/{course}', 'Api\CourseController@show');
    Route::get('/courses/{course}/edit', 'Api\CourseController@edit');
    Route::post('/courses', 'Api\CourseController@store')->middleware('permission:manage-course');
    Route::put('/courses/{course}', 'Api\CourseController@update')->middleware('permission:manage-course');
    Route::delete('/courses/{course}', 'Api\CourseController@destroy')->middleware('permission:manage-course');

    Route::get('/catalogs', 'Api\CataLogController@index');
    Route::get('/catalogs/{catalog}', 'Api\CataLogController@show');
    Route::get('/catalogs/{catalog}/edit', 'Api\CataLogController@edit');
    Route::post('/catalogs', 'Api\CataLogController@store')->middleware('permission:manage-course');
    Route::put('/catalogs/{catalog}', 'Api\CataLogController@update')->middleware('permission:manage-course');
    Route::delete('/catalogs/{catalog}', 'Api\CataLogController@destroy')->middleware('permission:manage-course');

    Route::post('/userCourse', 'Api\UserCourseController@store');
    // 我的二维码
    Route::get('/wechat/qrcode', 'Api\WechatController@qrcode');

    Route::resource('/levels', 'Api\LevelController');
    Route::resource('/upgrades', 'Api\UpgradeConbtroller');
    Route::get('/chats/unread', 'Api\ChatController@unread');


    ///////////////////////人才系统///////////////////////

    //人才系统 身份注册更新  人才系统初始化
    Route::post('/entrance', 'Api\UserPersonnelController@index');
    Route::put('/entrance/up', 'Api\UserPersonnelController@upUserInfo');
    /**
     * 开通vip
     * month   开通vip月数
     */
    Route::get('/getVipUnit', 'Api\UserPersonnelController@getVipUnit');//获取vip单价/月
    Route::get('/getVipTime', 'Api\UserPersonnelController@getVipOverTime');//获取vip到期时间
    Route::post('/openVip', 'Api\UserPersonnelController@openVip');
    //我的公司信息
    Route::get('/companyInfo', 'Api\CompanyInfo@index');//获取我的公司信息
    Route::post('/companyInfo/update', 'Api\CompanyInfo@update');
    //type=image-删除图片 type=video-删除视频 type=music-删除音频
    Route::post('/company/flaunt/delete', 'Api\CompanyInfo@flauntDeletes');
    //查看他人信息 uid-被查看者id    identity-1表示查看个人 2表示查看公司   is_pinggu-1表示显示个人评估 0表示不显示
    Route::get('/lookOthersInfo', 'Api\UserPersonnelController@lookOthersInfo');
    //职位列表  position_name  职位名称搜索
    Route::get('/zhiwei', 'Api\UserPersonnelController@zhiwei');
    //公司列表   cname   公司名称搜索
    Route::get('/gongsi', 'Api\UserPersonnelController@gongsi');
    //隐私设置
    //获取我的隐私设置
    Route::get('/myPrivac', 'Api\PrivacSetUpController@myPrivac');
    //修改我的隐私设置
    Route::put('/myPrivac/update', 'Api\PrivacSetUpController@updatePrivac');
    //简历模块
    //获取我的简历
    Route::get('/resume', 'Api\ResumeController@index');
    //刷新简历
    Route::put('/resume/refreshResume', 'Api\ResumeController@refreshResume');
    //基本信息
    Route::post('/resume/storeBasic', 'Api\ResumeController@storeBasic');
    Route::put('/resume/updateBasic', 'Api\ResumeController@updateBasic');
    //工作经验
    Route::post('/resume/storeWork', 'Api\ResumeController@storeWork');
    Route::put('/resume/updateWork', 'Api\ResumeController@updateWork');
    //教育背景
    Route::post('/resume/storeEducation', 'Api\ResumeController@storeEducation');
    Route::put('/resume/updateEducation', 'Api\ResumeController@updateEducation');
    //求职意向
    Route::post('/resume/storeIntention', 'Api\ResumeController@storeIntention');
    Route::put('/resume/updateIntention', 'Api\ResumeController@updateIntention');
    //语言能力
    Route::post('/resume/storeLanguage', 'Api\ResumeController@storeLanguage');
    Route::put('/resume/updateLanguage', 'Api\ResumeController@updateLanguage');
    //项目经验
    Route::post('/resume/storeProject', 'Api\ResumeController@storeProject');
    Route::put('/resume/updateProject', 'Api\ResumeController@updateProject');
    //个人简历图片和视频上传修改   image   video
    Route::post('/resume/flaunt', 'Api\ResumeController@flaunt');
    //type=image-删除图片 type=video-删除视频
    Route::post('/flaunt/delete', 'Api\ResumeController@flauntDeletes');

    //职位申请
    Route::post('/positionApply', 'Api\InterviewController@positionApply');
    //修改申请状态   0表示未查看  1表示已查看  2表示同意  3表示拒绝
    Route::put('/isConsent', 'Api\InterviewController@isConsent');
    //职位申请记录
    Route::get('/applicationRecord', 'Api\InterviewController@applicationRecord');

    //邀请面试
    Route::post('/yaoqing', 'Api\InterviewController@yaoqing');
    //修改邀请状态  0表示未查看  1表示已查看  2表示同意  3表示拒绝
    Route::put('/isInvite', 'Api\InterviewController@isInvite');
    //邀请记录
    Route::get('/yaoqongjilu', 'Api\InterviewController@yaoqongjilu');

    //发布职位
    Route::post('/releasePosition', 'Api\InterviewController@releasePosition');
    //修改职位
    Route::put('/updatePosition', 'Api\InterviewController@updatePosition');
    //我发布的职位
    Route::get('/myReleasePosition', 'Api\InterviewController@myReleasePosition');
    //根据职位id获取一条职位信息
    Route::get('/lookOnePosition', 'Api\InterviewController@lookOnePosition');
    //谁看过我
    Route::get('/whoLookMy', 'Api\WhoLookMyController@index');
    //关注  position_id   company_id  by_id
    Route::post('/follow', 'Api\FollowController@store');
    //我的关注
    Route::get('/myFollow', 'Api\FollowController@myFollow');

    //收藏   news_id
    Route::post('/shoucang/store', 'Api\CollectController@store');
    //取消收藏   news_id
    Route::post('/cancel/shoucang', 'Api\CollectController@delete');
    //我的收藏   分页
    Route::get('/shoucang', 'Api\CollectController@index');
    //人才列表
    Route::get('/talentsRecommend', 'Api\UserPersonnelController@talentsRecommend');

    //人才系统支付记录
    Route::get('/talents/order', 'Api\TalentsOrderController@index');


    //人才评估题目分类
    Route::resource('/subjectSort', 'Api\SubjectSortController');//题目分类
    Route::resource('/describes', 'Api\DescribesController');//题目描述
    Route::resource('/subject', 'Api\SubjectController');//题目
    /**
     * 购买评估机会
     * sort_id  购买哪套题目  题目分类id
     */
    Route::post('/subjectBuy', 'Api\SubjectPowerController@buy');
    /**
     * 团队评估
     * team_user_id   团队id   array
     */
    Route::post('/teamBuy', 'Api\SubjectPowerController@team');
    Route::get('/getTeamUnit', 'Api\SubjectPowerController@getTeamUnit');//获取团队评估单价===一个人需要多少钱
    Route::get('/subjectHome/{sort}', 'Api\SubjectController@home');//前端根据题目分类id获取题目
    Route::resource('/assessments', 'Api\AssessmentController');//后台评估结果处理
    Route::resource('/analysitical', 'Api\AnalysesController');//评估分析语句处理
    Route::post('/assessment/{sort}', 'Api\AssessmentController@pinggu');//前端提交做题结果
    //获取用户最新评估结果 可根据assessments_id获取指定评估结果
    Route::get('/GetAssessment/{user_id}', 'Api\AssessmentController@GetAssessment');
    //获取指定用户心理学评估历史记录
    Route::get('/GetAssessment/{user_id}/history', 'Api\AssessmentController@history');

//易经评估
    Route::resource('/yiJingIntroductionSort', 'Api\YiJingIntroductionSortController');//分析导语分类
    Route::resource('/YiJingIntroduction', 'Api\YiJingIntroductionController');//分析导语
    Route::resource('/yiJing', 'Api\YiJingController');//易经评估处理  包括前台用户自己删除自己的评估结果
    /**
     * 默认获取最新评估结果
     * sign==history 获取历史评估结果
     */
    Route::get('/getMyYiJing', 'Api\YiJingController@getMyYiJing');


    ////////////////////天南山文化论坛//////////////////////
    Route::resource('/forumSort', 'Api\ForumSortsController');//论坛分类
    Route::resource('/forumPost', 'Api\ForumPostController');//论坛帖子
    Route::get('/forumPosts/{id}', 'Api\ForumPostController@look');//贴子详情
    Route::post('/forum/zan', 'Api\ForumPostController@zan');//赞和取消点赞
    Route::resource('/forumComment', 'Api\ForumCommentController');//论坛评论

});
Route::post('/logout', 'Api\OAuthController@logout');
Route::get('/configs/byKey/{key}', 'Api\ConfigController@byKey');
Route::get('/comments', 'Api\CommentController@index');
Route::get('/ads/home', 'Api\AdController@home');
Route::get('/ads', 'Api\AdController@index');
Route::get('/goods/history', 'Api\GoodsController@history');
Route::get('/goods/{good}', 'Api\GoodsController@show')->name('goods.show');
Route::get('/goods', 'Api\GoodsController@index')->name('goods.index');
// 上传
Route::post('/upload/video', 'Api\BaseController@uploadVideo');//上传视频
Route::post('/upload/audio', 'Api\BaseController@uploadAudio');//上传音频
Route::post('/upload/file', 'Api\BaseController@uploadFile');
Route::post('/upload/editor', 'Api\BaseController@uploadEditorImage');
Route::post('/upload/image', 'Api\BaseController@uploadImage');
Route::post('/upload/thumbImage', 'Api\BaseController@uploadThumbImage');
Route::post('/upload/adImage', 'Api\BaseController@uploadAdImage');
Route::post('/upload/attachment', 'Api\BaseController@uploadAttachment');
Route::post('/upload/specImage', 'Api\BaseController@uploadSpecGoodsImage');
Route::post('/auth', 'Api\OAuthController@auth');
Route::post('/socialite/binding', 'Api\SocialiteOAuthController@binding');
Route::get('/socialite/{driver}', 'Api\SocialiteOAuthController@redirectToProvider')->middleware('web');
Route::get('/socialite/{driver}/callback', 'Api\SocialiteOAuthController@handleProviderCallback')->middleware('web');

Route::get('/chats/count/{to}', 'Api\ChatController@unreadCount');
Route::resource('/chats', 'Api\ChatController');

// wechat
Route::any('/wechat', 'Api\WechatController@wechat');
Route::any('/wechat/menu', 'Api\WechatController@menu');
Route::get('/wechat/login', 'Api\WechatController@officialAccountLogin')->middleware(['web', 'wechat.oauth:snsapi_userinfo']);
Route::get('/wechat/jssdk', 'Api\WechatController@jssdkConfig');
// notify
Route::post('/notify/{type}-{id}', 'Api\NotifyController@notify');
Route::post('/notify/donation/{type}-{id}', 'Api\NotifyController@donation');
Route::post('/notify/upgrade/{type}-{id}', 'Api\NotifyController@upgrade');
Route::post('/notify/course/{type}-{id}', 'Api\NotifyController@course');
Route::post('/notify/subject/{type}-{id}', 'Api\NotifyController@subject');
Route::post('/notify/team/{type}-{id}', 'Api\NotifyController@team');
Route::post('/vipNotify/{type}-{id}', 'Api\NotifyController@vipNotify');
// 每日红包
Route::get('/daily/coupons', 'Api\CouponController@daily');
Route::get('/test', 'Api\TestController@index');
